1. Field of the Invention
The present invention relates to computer systems for displaying graphics information and more particularly to processes for controlling data: variable values without using branching instructions.
2. Background and Related Art
Graphic display systems generate images on a display device in response to Graphic drawing commands. Graphic drawing commands are entered by a system operator using software for Computer Aided Design (CAD) or other drawing or "painting" software. The Graphic display is presented preferably as a color image or, less desirably, as a monochrome image having multiple shading levels.
Color graphics systems store a numerical value representing color in each picture element (pixel) position. This numerical value is extracted and sent to a digital to analog converter (DAC) that generates the color or shaded signal to the display device. The DAC uses a lookup table to transform the pixel value to the appropriate red, green, blue (RGB) and alpha signals. The lookup table accepts a variable value as input and typically outputs a color value in the range of 0 to 255 for each of the red, green and blue colors. The variable value is typically stored as a number between 0 and 1, though other ranges could be used.
Problems can occur when the value of the variable is outside of the expected range (i.e. greater than 1 or less than 0.) Prior art systems have implemented variable test code to test each variable value to make sure it is within the expected ranges. Each pixel receives its assigned value by operation on the vertices of the polygon in which the pixel appears. It is therefore sufficient to test the RGB and alpha values of each vertex to ensure they are within the necessary range. Limiting the test to vertices, however, still results in a large number of calculations for any complex figure with a large number of polygons and hence vertices.
Clamping a value x between a and c is expressed by the following equation: ##EQU1##
Prior art systems implement clamping by testing each value using the logic shown in equation (2).
float x, y, a, c; EQU y=x; (2) PA1 if (y&lt;a) y=a; PA1 else if (y&gt;c) y=c;
This equation uses branching instructions within the computer system (implementing if-then constructs.) Branching instructions are inefficient in most systems because they interrupt the instruction pipeline. System performance is significantly impacted by this conditional structure because the clamping must be done in totem-pole fashion for each color component red, green, blue and alpha. The alpha value controls transparency or anti-aliasing in the typical system. Totem-pole tests are performed one after the other thereby creating many branches and greatly degrading the pipeline system.
It is desirable to find a method for implementing clamping of variable values without impacting the efficiencies of the processor pipeline. Such a technique would result in significant processing speed improvement due to the large number of values that must be clamped in a graphics system.